﻿using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNet.SignalR;
using Microsoft.Owin;
using Microsoft.Owin.Cors;
using Owin;
using QuartzJob;
using QuartzJob.Jobs;

[assembly: OwinStartup(typeof(XF.Meeting.Api.App_Start.Startup))]

namespace XF.Meeting.Api.App_Start
{
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            //QuartzConfig.StartUpdateState();
            //QuartzConfig.GetWXInfo();
            //QuartzConfig.AddJobsForMinute<SendWxMsg>("wxSendMsg", 1, "");
          
            app.UseCors(CorsOptions.AllowAll);
            app.Use((context, next) =>

            {

                if (context.Request.Headers.Any(k => k.Key.Contains("Origin")) && context.Request.Method == "OPTIONS")

                {

                    context.Response.StatusCode = 200;

                    return context.Response.WriteAsync("handled");

                }
                return next.Invoke();

            });
        }
    }
}
